﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.Serialization.Formatters.Binary;
using System.Text;

namespace Entities
{
    public class ServerConfigManager
    {

        public static ServerConfig serverConfig;

        public ServerConfigManager()
        {
            serverConfig = null;    
        }


        public static void serializeServerConfig(ServerConfig sc, String path)
        {
            Stream stream = File.Open(path, FileMode.Create);
            BinaryFormatter bformatter = new BinaryFormatter();            
            bformatter.Serialize(stream, sc);
            stream.Close();
        }

        public static ServerConfig deserializeServerConfig(String path)
        {
            Stream stream = File.Open(path, FileMode.Open);
            BinaryFormatter bformatter = new BinaryFormatter();
          
            serverConfig = (ServerConfig)bformatter.Deserialize(stream);
            stream.Close();

            return serverConfig;
        }
    }
}
